﻿using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

namespace FireBillBook.DbMigrations.LocalPgsqlMigrations
{
    public partial class AddBasicSetting : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_TradingPlatforms",
                table: "TradingPlatforms");

            migrationBuilder.DropColumn(
                name: "Id",
                table: "TradingPlatforms");

            migrationBuilder.DropColumn(
                name: "TradingPlatformId",
                table: "ConsumptionRecords");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "TradingPlatforms",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true);

            migrationBuilder.AddColumn<string>(
                name: "DisplayName",
                table: "TradingPlatforms",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "TradingPlatform",
                table: "ConsumptionRecords",
                nullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_TradingPlatforms",
                table: "TradingPlatforms",
                column: "Name");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_TradingPlatforms",
                table: "TradingPlatforms");

            migrationBuilder.DropColumn(
                name: "DisplayName",
                table: "TradingPlatforms");

            migrationBuilder.DropColumn(
                name: "TradingPlatform",
                table: "ConsumptionRecords");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "TradingPlatforms",
                type: "text",
                nullable: true,
                oldClrType: typeof(string));

            migrationBuilder.AddColumn<int>(
                name: "Id",
                table: "TradingPlatforms",
                type: "integer",
                nullable: false,
                defaultValue: 0)
                .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

            migrationBuilder.AddColumn<int>(
                name: "TradingPlatformId",
                table: "ConsumptionRecords",
                type: "integer",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddPrimaryKey(
                name: "PK_TradingPlatforms",
                table: "TradingPlatforms",
                column: "Id");
        }
    }
}
